﻿
        var se, m = 0, h = 0, s = 0, ss = 0, isStart = true;
        function second() {
            if (ss > 0 && (ss % 100 == 0)) { s += 1; ss = 1; }
            if (s > 0 && (s % 60) == 0) { m += 1; s = 0; }
            if (m > 0 && (m % 60) == 0) { h += 1; m = 0; }
            t = h + "时" + m + "分" + s + "秒" + ss + "毫秒";
            document.getElementById("showtime").innerHTML = t;
            ss += 1;
        }
        function startclock() {
            if (se == null || se == 'undefined' || istrue)
                se = setInterval("second()", 1);
            istrue = false;
        }
        function pauseclock() { clearInterval(se); istrue = true; }
        function stopclock() { clearInterval(se); m = h = s = 0; istrue = true; }


        function myClose() { document.getElementById('Button1').click(); alert(t) };


        var xmlHttp;
        function showCustomer() {
            alert("start");
            xmlHttp = GetXmlHttpObject();
            if (xmlHttp == null) {
                alert("您的浏览器不支持AJAX！");
                return;
            }

            var d1 = new Date();
            var t = d1.getFullYear() + ":" + d1.getMonth() + ":"
            + d1.getDate() + ":" + d1.getHours() + ":" + d1.getMinutes() + ":" + d1.getSeconds() + ":" + d1.getMilliseconds()+":"+<%=x %>;

            var url = "WebTest_ajax.aspx?t=" + t; //传到服务端上
            xmlHttp.onreadystatechange = stateChanged;
            xmlHttp.open("GET", url, true);
            xmlHttp.send(null);
        }
        function stateChanged() {
            document.getElementById("sessiontext").innerHTML = xmlHttp.responseText;
        }
        function GetXmlHttpObject() {
            var xmlHttp = null;
            try {
                // Firefox, Opera 8.0+, Safari
                xmlHttp = new XMLHttpRequest();
            }
            catch (e) {
                // Internet Explorer
                try {
                    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch (e) {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
            }
            return xmlHttp;
        }

        function start() {
            var d1 = new Date();
            document.getElementById("date1").value = d1.getFullYear() + ":" + d1.getMonth() + ":"
            + d1.getDate() + ":" + d1.getHours() + ":" + d1.getMinutes() + ":" + d1.getSeconds() + ":" + d1.getMilliseconds()+":"+<%=x %>;
            document.getElementById('Button1').click()
        }

        function end() {
            document.getElementById("date2").value = new Date();
            document.getElementById('Button3').click()
            alert(document.getElementById("date2").value);
        }

        //window.onload = function (){start();}
        //window.onload = function () { startclock(); }
        window.onload = function(){alert("start");}
        window.onbeforeunload  = function(){return "end";}